package homework;

import javax.swing.text.html.StyleSheet;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * 生成10个0-100之间的不重复的随机数,并输出
 * @author Xiloer
 *
 */
public class Test03 {

	public static void main(String[] args) {
		List<String> list = new ArrayList<>();
		for (int i=0;i<=100;i++){
			list.add(i+"");
		}

		Random rand = new Random();
		List<String> randomList = new ArrayList<>();
		String random = list.get(rand.nextInt(101));
		int count = 0;
		while(true) {
			if (randomList.contains(random))
				random = list.get(rand.nextInt(101));
			else{
				randomList.add(random);
				count++;
			}
			if (count == 10)
				break;
		}
		System.out.print("[ ");
		for (int i=0;i<randomList.size();i++){
			System.out.print (randomList.get(i)+" ");
		}
		System.out.println("]");
	}
}
